import request from '@/utils/request.js'

export const login = (data) => {
   return request.post('/acUser/login', data, {
   headers: { 'Content-Type': 'application/json' }
   })
  }
export const register = (registerData) => {
  const params = new URLSearchParams();
  for (let key in registerData) {
    params.append(key, registerData[key])
  }
  return request.post('/admin/register', params)
}
export const getPendingApps = (params) => {
  return request.get('/admin/applications/pending', { params })
}
export const handleApplication = (data) => {
  return request.post('/admin/applications/handle', data)
}
export const getUserInfo = () => {
  return request.get('/admin/userInfo')
}

export const getOpenStackStats = () => {
  return request.get('/admin/stats/openstack')
}
  
export const getYunhongStats = () => {
  return request.get('/admin/stats/yunhong')
}

export const createTemplate = (data) => {
  return request.post('/api/templates', data)
}
export const getTemplates = (params) => {
  return request.get('/api/templates', { params })
}

export const deleteTemplate = (templateId) => {
  return request.delete(`/api/templates/${templateId}`)
}

export const getTemplatesByPage = (params) => {
  return request.get('/api/templates/page', { params })
}

export const getTemplatesAll = (params) => {
  return request.get('/api/templates/all', { params })
}

export const getProcessedApps = (params) => {
  return request.get('/admin/applications/processed', { params })
}
  

export const deleteProcessedApp = (applyId) =>{
  return request.delete(`/admin/applications/${applyId}`)
}
  
